package com.bawei.park2211a.fg


import com.alibaba.android.arouter.launcher.ARouter
import com.bawei.base.mvvm.BaseFragment

import com.bawei.park2211a.databinding.FragmentMineBinding
import com.bawei.park2211a.repair.RepairViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MineFragment : BaseFragment<FragmentMineBinding,RepairViewModel>() {
    override fun initView() {
        viewModel.reqair()
        binding.mineIVisit.setOnClickListener {
            ARouter.getInstance().build("/app/mine/MineApplyActivity").navigation()
        }
        binding.mineIAudit.setOnClickListener {
            ARouter.getInstance().build("/app/mine/MineAuditActivity").navigation()
        }
    }

    override fun initData() {
        viewModel.reqairSuccess.observe(this){ it ->
            var okNumber=0
            it.forEach {
                if (it.processingStatus=="处理中"||it.processingStatus=="已完成"){
                    okNumber++
                }
            }
            val fl = okNumber * 100 / it.size.toFloat()
            binding.repariNumber.text=it.size.toString()
            binding.repariRate.text="${fl.toInt()}%"
            binding.repariSatisfaction.text="4.8"
        }
    }

}